<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String contextPath = request.getContextPath();
	StatisticsCon con = (StatisticsCon) request.getAttribute("con");
	ToolBar toolbar = new ToolBar();
	toolbar.setTitle("销售统计");
	toolbar.put(new ToolBar.Item("查询", "uf_query()"));
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.zhangyj.component.ToolBar"%>
<%@page import="com.zhangyj.util.Tools"%>
<%@page import="com.zhangyj.entitis.StatisticsCon"%>
<%@page import="com.zhangyj.entitis.Dingdan"%>
<%@page import="java.io.Writer"%>
<%@page import="com.zhangyj.component.grid.HTMLTable"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>销售统计</title>
<%@include file="/WEB-INF/jsps/head.jsp"%>
<script type="text/javascript" src="<%=contextPath %>/common/calendar.js"></script>
<script type="text/javascript">
function uf_selDate(name) {
	selectDate(document.forms["form1"][name]);
}
function uf_selZdr(name) {
	var url= "<%=contextPath%>/selector/zdr.do";
	var obj = _open(url,400,600);
	if (obj) {
		var form = document.forms["form1"];
		form["zdrid"].value = obj["userid"];
		form["zdr"].value = obj["yhm"];
	}
}
function uf_query() {
	var form = document.forms["form1"];
	form.submit();
}
</script>
</head>
<body>
<%
	toolbar.writer(out);
%>
<div class="subcontent">
<form name="form1" action="<%=contextPath%>/tj/xstj.do">
<%
com.zhangyj.entitis.SystemParam systemParam = com.zhangyj.entitis.SystemParam.getSystemParam(request);
out.print(systemParam.toInput());
%>
<input type="hidden" name="zdrid" value="<%=con.getZdrid()%>">
<input type="hidden" name="_query" value="Y">
<table>
	<tr>
		<td>开始时间</td>
		<td><input type="text" name="begin" readonly="readonly" ondblclick="uf_selDate('begin')"
			value="<%=biuldDate(con.getBegin())%>" />
		<button onclick="uf_selDate('begin')">选择</button>
		</td>
		<td>结束时间</td>
		<td><input type="text" name="end" readonly="readonly" ondblclick="uf_selDate('end')"
			value="<%=biuldDate(con.getEnd())%>" />
		<button onclick="uf_selDate('end')">选择</button>
		</td>
	</tr>
	<tr>
		<td>制单人</td>
		<td><input type="text" name="zdr"
			value="<%=biuldNotNull(con.getZdr())%>" />
		<button onclick="uf_selZdr()">选择</button>
		</td>
		<td>订单状态</td>
		<td>
			<select name="zfbs">
				<%=biuldOption(con.getZfbs())%>
			</select>
		</td>
	</tr>
</table>
</form>
</div>
<%
HTMLTable ht = (HTMLTable)request.getAttribute("table");
if (ht != null) {
	ht.println(out); 
}
%>
</body>
</html>
<%!private String biuldDate(String date) {
		if (date == null || date.length() == 0) {
			return "";
		}
		return date.substring(0, 10);
	}

	private String biuldNotNull(String date) {
		if (date == null || date.length() == 0) {
			return "";
		}
		return date;
	}

	private String biuldOption(int zfbs) {
		StringBuilder buf = new StringBuilder();
		for (int i = 0; i < Dingdan.ZFBSLABEL.length; i++) {
			buf.append("<option value=\"").append(i).append("\"");
			if (zfbs == i) {
				buf.append(" selected = \"selected\"");
			}
			buf.append(">").append(Dingdan.ZFBSLABEL[i]).append("</option>");
		}

		return buf.toString();
	}%>